// --------------------
// -- TEST FUNCTIONS --
// --------------------
if(!tests.scenarios) {
	tests.scenarios = {};
}
tests.scenarios.ToolKit = {name: "ToolKit"};

tests.scenarios.ToolKit.GetParticipantNameReturnsRightValue = function(){
    // given
    var testString = "test";
    wave.participant.setId(testString + "@wave.google.com");
    
    // when
    var participantName = mindgraph.getParticipantName();
    
    // then
    var result = participantName === testString;
    
    return {
        result: result,
        resultMessage: participantName
    };
}

tests.scenarios.ToolKit.LogUsesConsole = function(){
    // given
    var oldconsole = console;
    console = createConsole();
    var testMessage = "testMessage";
    
    // when
    mindgraph.log(testMessage);
    
    var result = console.getCount() === 1 && console.getMessage() === testMessage;
    var resultMessage = console.getMessage();
    console = oldconsole;
    return {
        result: result,
        resultMessage: resultMessage
    };
}

tests.scenarios.ToolKit.GenerateIdCreatesNewId = function(){
    // given
    var testString = mindgraph.getParticipantName();
    var idCount = 10;
    mindgraph.idCount = idCount;
    
    // when
    var generatedId = mindgraph.generateElementId();
    
    // then
    var result = generatedId === (testString + idCount) && mindgraph.idCount === (idCount + 1);
    
    //	wave = undefined;
    return {
        result: result,
        resultMessage: generatedId
    };
}


tests.scenarios.ToolKit.UpdateCountSetsIdCountWhenHigher = function(){
    // given
    var testNumber = 31;
    var id = mindgraph.getParticipantName() + testNumber;
    mindgraph.idCount = testNumber - 3;
    
    // when 
    mindgraph.updateIdCount(id);
    
    // then
    var result = mindgraph.idCount === testNumber;
    var resultMessage = "IdCount: " + mindgraph.idCount;
    return {
        result: result,
        resultMessage: resultMessage
    };
}

tests.scenarios.ToolKit.DoesntUpdateIdCountWhenLower = function(){
    // given
    var testNumber = 9;
    var id = mindgraph.getParticipantName() + testNumber;
    mindgraph.idCount = testNumber + 5;
    
    // when 
    mindgraph.updateIdCount(id);
    
    // then
    var result = mindgraph.idCount === testNumber + 5;
    var resultMessage = "IdCount: " + mindgraph.idCount;
    return {
        result: result,
        resultMessage: resultMessage
    };
}

// ---------------------------
// -- END of TEST FUNCTIONS --
// ---------------------------

